package com.logic.landseaserver.service.impl;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.logic.common.exception.BusinessException;
import com.logic.common.util.QueryUtil;
import com.logic.landseaserver.persistence.read.SurveyOptionReadMapper;
import com.logic.landseaserver.persistence.read.SurveyQuestionReadMapper;
import com.logic.landseaserver.persistence.read.SurveyReadMapper;
import com.logic.landseaserver.service.ISurveyService;
import com.logic.landseaserver.ws.dto.SurveyDTO;

/**
 * @Author: Drake
 * @Date: 2017/4/18
 * @Description: 问卷工程接口实现类
 */
@Service
public class SurveyServiceImpl implements ISurveyService {
	
	@Autowired
	private SurveyReadMapper surveyReadMapper;
	@Autowired
	private SurveyQuestionReadMapper surveyQuestionReadMapper;
	@Autowired
	private SurveyOptionReadMapper surveyOptionReadMapper;

	@Override
	public void delete(String arg0) throws BusinessException {
		// TODO Auto-generated method stub

	}

	@Override
	public Object get(Integer arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int insert(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<?> query(QueryUtil arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void update(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub

	}

	@Override
	public Boolean validate(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Boolean validateForDelete(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Boolean validateForInsert(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Boolean validateForUpdate(Object arg0) throws BusinessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public SurveyDTO getSurvey(String surveyCode) throws BusinessException{
		SurveyDTO surveyDTO = new SurveyDTO();	
		surveyDTO=surveyReadMapper.selectBySurveyCode(surveyCode);
		surveyDTO.setSurveyQuestionDTO(surveyQuestionReadMapper.selectBySurveyId(surveyDTO.getId()));
		for(int i=0;i<surveyDTO.getSurveyQuestionDTO().size();i++){
			surveyDTO.getSurveyQuestionDTO().get(i).setSurveyOptionDTO(surveyOptionReadMapper.selectByQuestionId(surveyDTO.getSurveyQuestionDTO().get(i).getId()));
		}
		return surveyDTO;
	}

}
